<!DOCTYPE html>
<#assign dicSelect=JspTaglibs["http://www.casic304.cn/dicSelect"] />
<#assign secSelect=JspTaglibs["http://www.casic304.cn/secSelect"] />
<#assign fillDept=JspTaglibs["http://www.casic304.cn/fillDept"] />
<html>
<head>
    <meta charset="utf-8">
    <title>飞行试验奖惩管理基本信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
<div class="qbdms-bodyDiv">
    <div class="layui-table-view-body qbdms-add-view-body">
        <form class="formPreview layui-form"  requrl="${ctx}/qbdms/wQbdFlightJc/get"  lay-filter="wQbdFlightJcDataForm"  id="wQbdFlightJcDataForm">
            <div class="qbdms-formTitle" >飞行试验奖惩计划 <i  class="qbdms-returnOn closeWindow">返回</i></div>
            <div class="qbdms-formBody">
                <@fillDept.dept css="dragInfo temSpace" id="tbxx"/>
                <div class="layui-row">
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="飞行试验名称">飞行试验名称<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input   type="text" name="fxsymc"  placeholder="请输入"
                                     autocomplete="off" class="layui-input " maxlength="50" fieldname="fxsymc" lay-verify="required"  lay-reqtext="飞行试验名称是必填项">
                        </div>
                    </div>

                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="密级">密级<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <@secSelect.sec_select required=true  data_src=1 name="secret"/>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="年度">年度<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input lay-verify="required" type="text" name="nd"  placeholder="请输入"
                                   autocomplete="off" class="layui-input dateTimeFiled time-init year" maxlength="50" fieldname="nd" disabled>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="型号名称">型号名称<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <select id="xhmc" lay-verify="required" name="xhmc"   lay-filter="xhmc" lay-search=""  lay-reqtext="型号名称是必填项">
                            </select>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="项目类型">项目类型<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <select  lay-verify="required" name="xmlx"   lay-search=""  lay-reqtext="项目类型是必填项"></select>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="总体单位名称">总体单位名称<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <select  lay-verify="required" name="ztswmc"   lay-search=""  lay-reqtext="总体单位名称是必填项"></select>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="项目类别">项目类别<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <select  lay-verify="required" name="xmlb"   lay-search=""  lay-reqtext="项目类别是必填项"></select>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="项目阶段">项目阶段<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <select  lay-verify="required" name="xmjd"   lay-search=""  lay-reqtext="项目阶段是必填项"></select>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="初始奖励额度（万元）">初始奖励额度（万元）<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input lay-verify="required||money" type="text" name="csjled"  placeholder="请输入"
                                   autocomplete="off" class="layui-input " maxlength="12" fieldname="csjled" onkeyup="checkJE(this)"    lay-reqtext="初始奖励额度是必填项">
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="初始处罚额度（万元）">初始处罚额度（万元）<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input lay-verify="required||money" type="text" name="cscfed"  placeholder="请输入"
                                   autocomplete="off" class="layui-input " maxlength="12" fieldname="cscfed" onkeyup="checkJE(this)" lay-reqtext="初始处罚额度是必填项">
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="产品价格（参考值）（万元）">产品价格（参考值）（万元）<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input lay-verify="required||money" type="text" name="cpjg"  placeholder="请输入"
                                   autocomplete="off" class="layui-input " maxlength="50" fieldname="cpjg" onkeyup="checkJE(this)"  lay-reqtext="产品价格是必填项" >
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="P值">P值<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input lay-verify="required" type="text" name="pz"  placeholder="请输入P值"
                                   autocomplete="off" class="layui-input " maxlength="50" fieldname="pz"  onblur="sumJE(this)" lay-reqtext="P值是必填项" >
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="计划奖励总额度（万元）">计划奖励总额度（万元）<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input lay-verify="required" type="text" name="jhjlzed"  placeholder="请输入"
                                   autocomplete="off" class="layui-input " maxlength="50" fieldname="jhjlzed" onkeyup="checkJE(this)" disabled  >
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="计划处罚总额度（万元）（）">计划处罚总额度（万元））<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input lay-verify="required" type="text" name="jhcfzed"  placeholder="请输入"
                                   autocomplete="off" class="layui-input " maxlength="50" fieldname="jhcfzed" onkeyup="checkJE(this)" disabled >
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="备注">备注</label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" name="bz"  placeholder="请输入"
                                   autocomplete="off" class="layui-input " maxlength="500" fieldname="bz">
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="奖励工资总额合计（万元）">奖励工资总额合计（万元）<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input lay-verify="required" type="text" name="jlgzzehj"  placeholder="请输入"
                                   autocomplete="off" class="layui-input " maxlength="50" fieldname="jlgzzehj" onkeyup="checkJE(this)"disabled>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="减免利润上缴合计">减免利润上缴合计<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input lay-verify="required" type="text" name="jmlrsjhj"  placeholder="请输入"
                                   autocomplete="off" class="layui-input " maxlength="50" fieldname="jmlrsjhj" onkeyup="checkJE(this)" disabled>
                        </div>
                    </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="主管部门">主管部门<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <select  lay-verify="required" name="zgbm"   lay-search=""  lay-reqtext="主管部门是必填项"></select>
                        </div>
                    </div>
                    <div class="qbdms-textarea">
                        <label class="layui-form-label qbdms-label">附件</label>
                        <div class="layui-input-block qbdms-input">
                            <div class="doNotDelThisDiv layui-input-inline">
                                <div class="uploadFileCont">
                                    <input type="button" lay-verify="fileRequired"
                                           class="layui-btn fileUpload qbdms-fileUp iconfont iconupload"
                                           value="上传附件" id="fManagecerfileList" name="fManagecerfileList">
                                    <i class="qbdms-fileUpText">支持单个附件上传，附件格式：doc docx pdf，文件大小限制不超过200M</i>
                                    <input type="text" id="fj" class="uploadInput" name="fj" fieldname="fj" style="display: none" >
                                    <div class="uploadFileList" fileUploadName="fj"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <p class="qbdms-SubTableTitle"><span>奖惩金额分配</span><i class="qbdms-fileUpText"></i></p>
            <div class="qbdms-tableDiv">
                <a modetype="2" class="addFormTr1"
                   id="add" style="display: none"><i class="layui-icon layui-icon-addition" style="display: none"></i>新增</a>
                <table class="qbdms-temTable wQbdFlightJczbList subFormTable"
                       id="wQbdFlightJczbList" style="min-width: 1360px;">
                    <tbody>
                    <tr class="temSpace qbdms-temTable-thead">
                        <td class="temSpace" style="width: 30px;">
                            序号
                        </td>
                        <td class="temSpace subDialogShowState">
                            奖励单位名称<span style="color: red;">*</span>
                        </td>
                        <td class="temSpace subDialogShowState" style="width: 90px">
                            单位类别<span style="color: red;">*</span>
                        </td>
                        <td class="temSpace subDialogShowState" style="width:90px">
                            分配比例(%)<span style="color: red;">*</span>
                        </td>
                        <td class="temSpace subDialogShowState " style="width: 170px">
                            计划最高奖励额度（万元)<span style="color: red;">*</span>
                        </td>
                        <td class="temSpace subDialogShowState" style="width: 180px">
                            计划最高处罚额度（万元）<span style="color: red;">*</span>
                        </td>
                        <td class="temSpace subDialogShowState" style="width: 180px">
                            奖励工资总额合计（万元）<span style="color: red;">*</span>
                        </td>
                        <td class="temSpace subDialogShowState" style="width: 180px">
                            减免利润上缴合计（万元）<span style="color: red;">*</span>
                        </td>
                    </tr>
                    <tr class="temSpace subContTem">
                        <td class="temSpace qbdms-temTable-seNumber">
                            <div class="temTag">0</div>
                        </td>
                        <td class="temSpace qbdms-temTable-td">
                            <select  requiredFlag="required" name="s:wQbdFlightJczbList:jlswmc"   lay-search="" lay-reqtext="奖励单位名称是必填项"></select>
                        </td>

                        <td class="temSpace qbdms-temTable-td">
                            <select  requiredFlag="required" name="s:wQbdFlightJczbList:swlb"  lay-filter="swlb"   lay-search="" lay-reqtext="单位类别是必填项"></select>
                        </td>

                        <td class="temSpace qbdms-temTable-td ">
                            <input type="text" placeholder="请输入" autocomplete="off" class="layui-input "
                                   name="s:wQbdFlightJczbList:fpbl" maxlength="50" requiredFlag="required" onblur="tjsumZB()" lay-reqtext="分配比例是必填项">
                        </td>
                        <td class="temSpace qbdms-temTable-td qbdms-money">
                            <input type="text" placeholder="请输入" autocomplete="off" class="layui-input "
                                   name="s:wQbdFlightJczbList:jhzgjled" maxlength="50" requiredFlag="required" onkeyup="checkJE(this)" disabled>
                        </td>
                        <td class="temSpace qbdms-temTable-td qbdms-money">
                            <input type="text" placeholder="请输入" autocomplete="off" class="layui-input "
                                   name="s:wQbdFlightJczbList:jhzgcfed" maxlength="50" requiredFlag="required" onkeyup="checkJE(this)" disabled>
                        </td>

                        <td class="temSpace qbdms-temTable-td qbdms-money">
                            <input type="text" placeholder="请输入" autocomplete="off" class="layui-input "
                                   name="s:wQbdFlightJczbList:jlgzzehj" maxlength="50" requiredFlag="required" onkeyup="checkJE(this)" disabled>
                        </td>
                        <td class="temSpace qbdms-temTable-td qbdms-money">
                            <input type="text" placeholder="请输入" autocomplete="off" class="layui-input "
                                   name="s:wQbdFlightJczbList:jmlrsjhj" maxlength="50" requiredFlag="required" onkeyup="checkJE(this)" disabled>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>


            <div class="layui-hide">
                <input type="text" name="id" placeholder="请输入" autocomplete="off" class="layui-input "
                       maxlength="50" fieldname="id">
                <input type="text" name="fillman" placeholder="请输入"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="fillman">
                <input type="text" name="fillmanaccount" placeholder="请输入"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="fillmanaccount">
                <input type="text" name="filldept" placeholder="请输入"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="filldept">
                <input type="text" name="filldeptid" placeholder="请输入填写部门id"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="filldeptid">
                <input type="text" name="filldepthospital" placeholder="请输入"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="filldepthospital">
                <input type="text" name="filldepthospitalid" placeholder="请输入二级部门id"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="filldepthospitalid">
                <input type="text" name="filldate" placeholder="请输入"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="filldate">
                <input type="text" name="fMainunitid" placeholder="请输入主承担单位ID"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="fMainunitid">
                <input type="text" name="createTime" placeholder="请输入"
                       autocomplete="off" class="layui-input" maxlength="50"
                       fieldname="createTime">
                <input type="text" name="createBy" placeholder="请输入"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="createBy">
                <input type="text" name="updateTime" placeholder="请输入"
                       autocomplete="off" class="layui-input dateTimeFiled time-init" maxlength="50"
                       fieldname="updateTime">
                <input type="text" name="updateBy" placeholder="请输入"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="updateBy">
                <input type="text" name="tenantId" placeholder="请输入租户Id"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="tenantId">
                <input type="text" name="reportStatusTemp" placeholder="请输入"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="reportStatusTemp">
                <input type="text" name="reportStatus" placeholder="请输入"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="reportStatus">
                <input type="text" name="reportDate" placeholder="请输入"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="reportDate">
                <input type="text" name="reportReason" placeholder="请输入"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="reportReason">
                <input type="text" name="returnmsg" placeholder="请输入"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="returnmsg">
                <input type="text" name="fTechnology" placeholder="组织负责人code"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="returnmsg">
            </div>
            <div class="layui-form-item btnformItem">
                <p>
                    <span id="hideAndShow" style="display: none;">
                        <a lay-submit lay-filter="wQbdTecBasicmanage" class="layui-btn btn-n privateSubmit qbdms-oneBtn"
                           requrl="${ctx}/qbdms/wQbdFlightJc/save">提交</a>
                    </span>
                    <button type="reset" id="closeWindow" style="margin-left: 10px;"
                            class="layui-btn layui-btn-sm btn-save qbdms-oneBtnLine">取消
                    </button>
                </p>
            </div>
        </form>
    </div>
</div>
</div>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'setter', 'form', 'layer','table','propsHandle', 'common', 'laydate', 'jquery', 'publicMethods'], function () {
        // -----常量声明----------
        var $ = layui.jquery,
            laydate = layui.laydate,
            publicMethods = layui.publicMethods,
            setter = layui.setter,  // 配置信息
            layer = layui.layer,
            propsHandle = layui.propsHandle,
            form = layui.form,
            formId = '${formDefId}' || '',
            defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                formAreaInfo: 'html',
                temDate: '.temDate',
                uploadFileBtn: '.uploadFileBtn',
                uploadImgBtn: '.uploadImgBtn',
                richTextArea: '.richTextArea',
                selectInput: '.selectInput',
                radioOptionCont: '.radioOptionCont',
                dataLexiTree: '.dataLexiTree',
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle()  // 实例化模板功能部分
        ;
        // $("[lay-verify='required']").attr("lay-verify", "");
        //- 添加表单验证规则 开始 ---------------------------------------------------------------------
        form.verify({
            integer: [/^[+]{0,1}(\d+)$/,'请输入正整数'],
            money: [/^((0{1}\.\d{1,2})|([1-9]\d*\.{1}\d{1,2})|([1-9]+\d*))$/,'请输入合适金额'],
            length100:[/^.{0,100}$/,'输入字符数不能超过100'],
            length2000:[/^.{0,2000}$/,'输入字符数不能超过2000'],
            fileRequired:[/[\S]+/,"没有上传对应附件"],
        });
        //- 添加表单验证规则 结束 ---------------------------------------------------------------------

        // 初始化模板功能
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });

        // 子表初始化事件
        temQuery.initSubEvent(defProps, serverPath, setter);
        var currentDate = new Date();
        var currentYear = currentDate.getFullYear();
        var dateTimeFiledLen = $(".dateTimeFiled");
        for (var i = 0; i < dateTimeFiledLen.length; i++) {
            laydate.render({
                elem: dateTimeFiledLen[i] //指定元素
                , type: 'year'
                , trigger: 'click'
                ,min:currentYear.toString()
            });
        }
        //关闭当前页面
        $("#closeWindow,.closeWindow").click(function () {
            var mdb = "${db}";
            if(null != mdb && 'db' === mdb && undefined != mdb){
                window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdFlightJc/view/list';
                return;
            }
            window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdFlightJc/view/list';
        });
        var runId = "${runId}";
        if (runId == null || runId == '') {
            $("#hideAndShow").show();
        }

        var common = layui.common;
        var index = parent.layer.getFrameIndex(window.name);
        common.updateForm({
            name: 'wQbdFlightJcDataForm',
            idValue: "${id}",
            primary: "id",
            beforeSubmitFun: function(data){
                var newD = data.field.nd;
                data.field.nd = new Date(newD);
                var ztswmcstr = $("select[name='ztswmc']").next(".layui-form-select").find(".layui-select-title>.layui-input").val();
                data.field.ztswmcstr = ztswmcstr;
                //- 子表数据 开始 ------------------------------------------------------
                var sub = [];
                $('table.subFormTable').each(function () {
                    var table = {
                        tableName: $(this).attr('class').split(" ")[1],
                        fields: []
                    };
                    $(this).find('tr.temSpace').each(function (i, item) {    /*修复需要提交隐藏的行数据的bug*/
                        if (i > 1) {
                            var row = {};
                            var objRow = $(this);
                            $("input:text[name^='s:'],input[type='hidden'][name^='s:'],textarea[name^='s:'],select[name^='s:'],ul[name^='m:']", objRow).each(function () {
                                var name = $(this).attr('name').replace(/.*:/, '');
                                row[name] = $(this).val();
                            });
                            var jlswmcstr = objRow.find("select[name='s:wQbdFlightJczbList:jlswmc']").next(".layui-form-select").find(".layui-select-title>.layui-input").val();
                            row['jlswmcstr'] = jlswmcstr;
                            row["sort"] = i - 1;
                            table.fields.push(row);
                        }
                    });
                    data.field[table.tableName] = table.fields;
                    sub.push(table.fields);
                });
                //- 子表数据 结束 ------------------------------------------------------
                //判断奖惩单位名称是否重复
                var arr = [];
                var subData = sub[0];
                for(var i=0;i<subData.length;i++){
                    arr.push(subData[i].jlswmc);
                }
                var rewardsUnitNameIsExist = false;
                var nary=arr.sort();
                for(var i=0;i<nary.length;i++){
                    if (nary[i]==nary[i+1]){
                        layer.msg("重复的奖惩单位名称", {icon: 5});
                        rewardsUnitNameIsExist = true;
                        return  false;
                    }
                }
                var files=[];
                //整理上传附件的隐藏域，将提交的字符串转为json对象
                $(".uploadInput").each(function(){
                    var uploadName = $(this).attr("name");
                    if (!$(this).val()) {
                        return;
                    }
                    data.field[uploadName] = eval($(this).val());
                    files=files.concat(eval($(this).val()));
                });



                //- 附件密级不能高于表单密级 开始 ------------------------------------------------------
                var selectMaxVal = 0;
                var formSecretVal = $("[name='secret']").val();
                $(".fileSecLevel select").each(function () {
                    selectMaxVal = selectMaxVal >= $(this).val() ? selectMaxVal : $(this).val();
                });

                if (selectMaxVal > formSecretVal) {
                    layer.msg('附件密级不能高于表单密级。', {icon: 5});
                    return false;
                }
                //- 附件密级不能高于表单密级 结束 ------------------------------------------------------
                return common.setFileLevel(files);

            },
            getCallback: function(data) {
                //-修改页面 初始化子表 开始 ------------------------------------------
                $('table.subFormTable').each(function () {
                    var table = {
                        tableName: $(this).attr('class').split(" ")[1],
                        fields: []
                    };
                    table.fields = data.data[table.tableName];
                    if(table.fields.length==0){
                        $(this).parent(".qbdms-tableDiv").append("<p>无数据</p>")
                    }else {
                        $(this).parent(".qbdms-tableDiv").css('padding',"0px")
                    }
                    for (var i = 0, len = table.fields.length; i < len; i++) {
                        var dataRow = table.fields[i];
                        var temp = $("." + table.tableName).prev().click();
                        //这里有子表表头占一行，子表隐藏行占一行，所以取需要赋值的行时，需要temp=i+2
                        var domRow = $(this).find("tr.temSpace:eq(" + (i * 1 + 2) + ")");
                        $.each(dataRow, function (j, val) {
                            var domItem = domRow.find("[name$='" + j + "']");
                            if (domItem) {
                                domItem.val(val);
                            }
                        });
                    }
                });
                //-修改页面 初始化子表附件组件 开始 ------------------------------------------.
                $('.uploadFileList').each(function () {
                    var fileUploadName = $(this).attr("fileUploadName");
                    var jsonFile = data.data[fileUploadName];
                    var files = eval(jsonFile);

                    if (files) {
                        for (var i = 0; i < files.length; i++) {
                            var fileLevel = files[i].fileLevel;
                            var fileLevelText = files[i].fileLevelText;
                            var fileSec = '<div class="fileSecLevel fileSecXg layui-input-inline">' + '<@secSelect.sec_select data_src=1 hasBlank=false/>' + "</div>";
                            var newStr = '<span class="file-id" style="margin-right: 20px;" fileId=' + files[i].fileId + ' fileLevelText="' + fileLevelText + '">' + fileSec + '<span class="file-name" title="点击下载文件" onclick="downFile(this)"><i class="iconfont data-iconcommon_fujian" style="margin-right: 5px"></i>' + files[i].fileName + '</span><i class="iconfont data-iconcommon_close deleteFile" ></i></span>';
                            // newStr = '<span class="file-id" style="margin-right: 20px;" fileId=' + files[i].fileId + '><span class="file-name" onclick="downFile(this)">' + files[i].fileName + '</span><i class="layui-icon layui-icon-delete deleteFile" ></i></span>';
                            $(this).html(newStr);
                            $(this).find("select:last").val(fileLevel);
                            // $(this).find("select:last").attr("disabled", "disabled");
                        }
                    }
                });
            },
            updateCallback: function (data) {
                if (common.filterRecord(data)) {
                    if ($(".privateSubmit")) {
                        $(".privateSubmit").attr("disabled", false).css("pointer-events", "auto");
                    }
                   layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'}, function (index) {
                        layer.close(index);
                        window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdFlightJc/view/list';
                    });
                } else {
                    layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                }
                return false;
            }
        });

        //-- 初始化 数据字典 开始 --------------------------------------------------------------

        var projectList = eval('${projectList}'); //飞行试验项目
        common.initDicData("projectId", projectList);

        // var mjList = eval('${mjList}'); //密级
        // common.initDicData("secret", mjList);

        var xhmcList = eval('${xhmcList}'); //型号名称
        common.initDicData("xhmc", xhmcList);


        var xmlxList = eval('${xmlxList}'); //项目类型
        common.initDicData("xmlx", xmlxList);


        var ztdwmcList = eval('${ztdwmcList}'); //总体单位名称
        common.initDicData("ztswmc", ztdwmcList);


        var ztdwmcList = eval('${ztdwmcList}'); //奖励单位名称
        common.initDicData("s:wQbdFlightJczbList:jlswmc", ztdwmcList);


        var xmlbList = eval('${xmlbList}'); //项目类别
        common.initDicData("xmlb", xmlbList);


        var xmjdList = eval('${xmjdList}'); //项目阶段
        common.initDicData("xmjd", xmjdList);

        var zgbmList = eval('${zgbmList}'); //主管部门
        common.initDicData("zgbm", zgbmList);


        var swlbList = eval('${swlbList}'); //单位类别
        common.initDicData("s:wQbdFlightJczbList:swlb", swlbList);

        var secSelect = '<@secSelect.sec_select data_src=1 hasBlank=false/>'
        common.uploadfun(".fileUpload",{
            acceptMime:'${wjszsdsxlx}',
            exts:'${fileManagementUploadType}',
            secSelect:secSelect,
            isSub:false
        })

        form.render();
        //-- 初始化 数据字典 结束 --------------------------------------------------------------

        //时间戳转换方法    date:时间戳数字
        function formatDate(date) {
            var date = new Date(date);
            var YY = date.getFullYear();
            return YY;
        }

        window.sumJE= function sumJE(e) {
            if(/^(0.\d+|1)$/.test(e.value)==false){
                e.value=""
                return  false
            }
            //计划奖励总额度
            var data= form.val("wQbdFlightJcDataForm");
            var nd=data.nd;
            var V= data.csjled;
            var P=e.value;
            var a=1;
            if(parseInt(nd)==parseInt(2020)){
                a=0.8;
            }
            if(parseInt(nd)==parseInt(2019)){
                a=0.5;
            }
            var Q=P/0.75;
            var jhjlzed=V*a*Q+V*(1-a);

            //计划处罚总额
            var U=data.cscfed;
            var jhcfzed=U*a/Q+U*(1-a);


            form.val("wQbdFlightJcDataForm", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
                "jhjlzed":moneyFormat(jhjlzed)//
                ,   "jhcfzed":moneyFormat(jhcfzed)
            });
            tjsumZB();
        }

        form.on('select(swlb)',function (data) {
            tjsumZB();
        });
        window.tjsumZB=  function tjsumZB() {
            var data= form.val("wQbdFlightJcDataForm");
            var jhjlzed=data.jhjlzed;
            var jhcfzed=data.jhcfzed;
            var jhzgjl=[];  //计划最高奖励额度 数组
            var jhzgcf=[];
            $("input[name='s:wQbdFlightJczbList:fpbl']").each(function(){
                var fpbl=$(this).val()/100;
                // 计划最高奖励额度
                var jhzgjled=jhjlzed*fpbl;
                jhzgjl.push(jhzgjled);
                // 计划最高处罚额度
                var jhzgcfed=jhcfzed*fpbl;
                jhzgcf.push(jhzgcfed);

            })
            var jhzgjled = $("input[name='s:wQbdFlightJczbList:jhzgjled']");
            for(var i=0;i<jhzgjled.length;i++){
                jhzgjled[i].value= moneyFormat(jhzgjl[i])
            }
            var jhzgcfed = $("input[name='s:wQbdFlightJczbList:jhzgcfed']") ;
            for(var i=0;i<jhzgcfed.length;i++){
                jhzgcfed[i].value= moneyFormat(jhzgcf[i])
            }
            var jlgzzehj=[0];
            var jmlrsjhj=[0];
            //计算奖励 工资总额合计（万元）*   减免利润上缴合计（万元）
            $("select[name='s:wQbdFlightJczbList:swlb']").each(function(i){
                var swlb=$(this).val();
                if(swlb=="上市公司"){
                    jlgzzehj.push(moneyFormat(jhzgjl[i]));
                    jmlrsjhj.push(0)
                }
                if(swlb=="非上市公司"){
                    jlgzzehj.push(moneyFormat(jhzgjl[i]*0.8));
                    jmlrsjhj.push(moneyFormat(jhzgjl[i]*0.2));
                }
            })


            var jlgzzehj_V = $("input[name='s:wQbdFlightJczbList:jlgzzehj']") ;
            for(var i=0;i<jlgzzehj.length;i++){
                jlgzzehj_V[i].value=moneyFormat(jlgzzehj[i])

            }
            var jmlrsjhj_V = $("input[name='s:wQbdFlightJczbList:jmlrsjhj']") ;
            for(var i=0;i<jmlrsjhj.length;i++){
                jmlrsjhj_V[i].value=moneyFormat(jmlrsjhj[i])
            }
            $("input[name='jlgzzehj']").val(moneyFormat(SumNum(jlgzzehj)));
            $("input[name='jmlrsjhj']").val(moneyFormat(SumNum(jmlrsjhj)));
        }

        //构建file的字符串
        function constructFileStr(){
            var filesJsonStr = "";
            $(this).find(".file-id").each(function(){
                var fileId = $(this).attr("fileid");
                var fileName = $(this).find("span").text();
                var fileLevel = $(this).find("option:selected").val();
                var fileLevelText = $(this).find("option:selected").text();
                filesJsonStr += '{"fileId":"' + fileId + '","fileName":"' + fileName + '","fileLevel":"' + fileLevel + '", "fileLevelText":"' + fileLevelText + '"},';
            });
            filesJsonStr = filesJsonStr.substring(0,filesJsonStr.length-1);
            if (filesJsonStr != "") {
                filesJsonStr = '['+filesJsonStr+']';
            }
            var fileUploadName = $(this).attr("fileUploadName");
            $("#" + fileUploadName).val(filesJsonStr);
        }

        //-- 附件上传 开始 --------------------------------------------------------------
        //下载附件
        window.downFile = function (obj){
            var fileId =  $(obj).parents("span").attr("fileId");
            window.location.href = serverPath.qbdmsPath + setter.extendLinkPath + "attachFile/download?fileId="+fileId;
        }
        // 删除
        $(document).on('click', '.deleteFile', function () {
            $(".uploadFileList").each(constructFileStr);
        });

        $(".subContTem").hide()
        //-- 子表数据 结束 --------------------------------------------------------------
        var count = 1;
        $(document).on('click', '.addFormTr1', function () {
            count += 1;
            var modetype = $(this).attr('modetype'),
                copyObj = $(this).parent().children('.subFormTable'),
                copyHtm = copyObj.find('tr').eq(1);
            if (modetype === '2') {
                //在这里做一个转换，控制子表隐藏行的必填
                var copyHtmlStr = copyHtm.html();
                copyHtmlStr = copyHtmlStr.replace(/requiredflag/g, "lay-verify");
                // 表格
                copyObj.append('<tr class="temSpace">' + copyHtmlStr + '</tr>');
                // copyObj.append('<tr class="temSpace">' + copyHtm.html() + '</tr>');
                var trArr = copyObj.find('tr');
                trArr.eq(trArr.length - 1).find('td').eq(0).find('.temTag').html(trArr.length - 2);
                // trArr.eq(trArr.length - 1).find('td').eq(6).find('button').attr("id","fSkillcerfileList"+count);
                trArr.eq(trArr.length - 1).find('.fileUpload').attr("id", "fSkillcerfileList" + count);

                trArr.eq(trArr.length - 1).find('[isinit="1"]').each(function (i, item) {
                    $(item).attr('isinit', '2');
                });
                if (trArr.length > 3) {
                    trArr.eq(trArr.length - 1).find('[type=radio]').each(function (i, item) {
                        $(item).attr('name', (trArr.eq(1).find('[type=radio]').eq(i).attr('name')) + '_' + (trArr.length - 2))
                    });
                }
                temQuery.initTemEvent(defProps, serverPath, setter);
            }
            form.render();
        });


    });

    function SumNum(arr) {
        var sum = eval(arr.join("+"));
        return sum;
    }

    function moneyFormat(val){
        if(val == "" || val == null){
            return "0.00";
        }
        var value=Math.round(parseFloat(val)*100)/100;
        var xsd=value.toString().split(".");
        if(xsd.length == 1){
            value=value.toString()+".00";
            return value;
        }
        if(xsd.length>1){
            if(xsd[1].length<2){
                value=value.toString()+"0";
            }
            return value;
        }
    }

    function checkJE(e) {
        e.value=e.value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'').replace('.','$#$').replace(/\./g,'').replace('$#$','.').replace(/\.{2,}/g,'.').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');
    }
    function checkPz(o) {
        if(/^(0.\d+|0|1)$/.test(o.value)){
            return true;
        }else{
            o.value=""
            return  false
        }
    }

</script>

</body>
</html>